<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** @fileOverview 对KISSY进行扩展的一些帮助函数
<span class='line'>  2</span> * 包括：屏蔽层，格式化函数，Form帮助类
<span class='line'>  3</span> * @author &lt;a href="mailto:dxq613@gmail.com">董晓庆 旺旺：dxq613&lt;/a>  
<span class='line'>  4</span> * @version 1.0.1  
<span class='line'>  5</span> */</span><span class="WHIT">
<span class='line'>  6</span> </span><span class="NAME">KISSY.add</span><span class="PUNC">(</span><span class="STRN">"gallery/grid/1.0/util"</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">S</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  7</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.DOM</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.Event</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>  9</span> </span><span class="WHIT">        </span><span class="NAME">win</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">,</span><span class="NAME">UA</span><span class="PUNC">=</span><span class="NAME">S.UA</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> 
<span class='line'> 11</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 12</span> 	* @memberOf Grid
<span class='line'> 13</span> 	* @name Util
<span class='line'> 14</span> 	* @class
<span class='line'> 15</span> 	*/</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 17</span> 
<span class='line'> 18</span> </span><span class="WHIT">	</span><span class="NAME">S.mix</span><span class="PUNC">(</span><span class="NAME">Util</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">	</span><span class="COMM">/** @lends  Grid.Util */</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 22</span> 		* @description 屏蔽整个页面: &lt;br> 1）ie 6,ie 7下设置100%无效 &lt;br> 2) 兼容浏览器的可视区域和内容区域
<span class='line'> 23</span> 		* @example 
<span class='line'> 24</span> 		*	Grid.Util.mask();	//屏蔽窗口
<span class='line'> 25</span> 		*	Grid.Util.unmask();	//解除屏蔽窗口
<span class='line'> 26</span> 		*/</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">		</span><span class="NAME">mask</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bodyEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="STRN">'body'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">				</span><span class="NAME">bodyHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bodyEl.height</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">				</span><span class="NAME">viewHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DOM.viewportHeight</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">				</span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bodyHeight</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">viewHeight</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="NAME">bodyHeight</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">viewHeight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">				</span><span class="NAME">maskEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Util.maskElement</span><span class="PUNC">(</span><span class="NAME">bodyEl</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">			</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">			</span><span class="NAME">maskEl.height</span><span class="PUNC">(</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">			</span><span class="NAME">Event.on</span><span class="PUNC">(</span><span class="NAME">win</span><span class="PUNC">,</span><span class="STRN">'resize'</span><span class="PUNC">,</span><span class="NAME">resizeEvent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">			</span><span class="NAME">maskEl.data</span><span class="PUNC">(</span><span class="STRN">'reszieFunc'</span><span class="PUNC">,</span><span class="NAME">resizeEvent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">funcId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">			</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">resizeEvent</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 39</span> 
<span class='line'> 40</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">funcId</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">				</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">					</span><span class="NAME">clearTimeout</span><span class="PUNC">(</span><span class="NAME">funcId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">				</span><span class="NAME">funcId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="NAME">setHeight</span><span class="PUNC">,</span><span class="NUMB">300</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 46</span> 
<span class='line'> 47</span> </span><span class="WHIT">			</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">setHeight</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">viewHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DOM.viewportHeight</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">					</span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bodyHeight</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">viewHeight</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="NAME">bodyHeight</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">viewHeight</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">				</span><span class="NAME">maskEl.height</span><span class="PUNC">(</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 54</span> 			@description 取消屏蔽整个页面
<span class='line'> 55</span> 		*/</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="NAME">unmask</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bodyEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="STRN">'body'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">				</span><span class="NAME">maskEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bodyEl.children</span><span class="PUNC">(</span><span class="STRN">'.lp-el-mask'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">				</span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">maskEl.data</span><span class="PUNC">(</span><span class="STRN">'reszieFunc'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">				</span><span class="NAME">Event.remove</span><span class="PUNC">(</span><span class="NAME">win</span><span class="PUNC">,</span><span class="STRN">'resize'</span><span class="PUNC">,</span><span class="NAME">func</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">				</span><span class="NAME">maskEl.data</span><span class="PUNC">(</span><span class="STRN">'reszieFunc'</span><span class="PUNC">,</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">			</span><span class="NAME">Util.unmaskElement</span><span class="PUNC">(</span><span class="NAME">bodyEl</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 67</span> 		* @description 屏蔽指定元素
<span class='line'> 68</span> 		* @param {[String|DOM|Node]} element 屏蔽的元素，可以使用选择器、Dom元素，Node元素
<span class='line'> 69</span> 		* @param {String} msg 屏蔽层上显示的信息，可以为空
<span class='line'> 70</span> 		* @param {String} msgCls 屏蔽信息上应用的CSS,可以为空，此项仅在 msg有效时起作用
<span class='line'> 71</span> 		* @example 
<span class='line'> 72</span> 		*	Grid.Util.maskElement('#domId');	//屏蔽元素，暂时只屏蔽选择器的第一个元素
<span class='line'> 73</span> 		*/</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">		</span><span class="NAME">maskElement</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">msgCls</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">maskedEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">				</span><span class="NAME">maskedNode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">maskedEl.getDOMNode</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">				</span><span class="NAME">maskDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="STRN">'.lp-el-mask'</span><span class="PUNC">,</span><span class="NAME">maskedNode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">maskDiv</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">maskDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="NAME">DOM.create</span><span class="PUNC">(</span><span class="STRN">'&lt;div class="lp-el-mask">&lt;/div>'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">appendTo</span><span class="PUNC">(</span><span class="NAME">maskedNode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">				</span><span class="NAME">maskedEl.addClass</span><span class="PUNC">(</span><span class="STRN">'x-masked-relative x-masked'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">UA.ie</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">					</span><span class="NAME">maskDiv.height</span><span class="PUNC">(</span><span class="NAME">maskedEl.height</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">msg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'&lt;div class="lp-el-mask-msg">&lt;div>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>&lt;/div>'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">						</span><span class="NAME">msgDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="NAME">DOM.create</span><span class="PUNC">(</span><span class="NAME">template</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">appendTo</span><span class="PUNC">(</span><span class="NAME">maskedNode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">msgCls</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">						</span><span class="NAME">msgDiv.addClass</span><span class="PUNC">(</span><span class="NAME">msgCls</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">					</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">left</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">maskedEl.width</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">msgDiv.width</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">							</span><span class="NAME">top</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">maskedEl.height</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">msgDiv.height</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">						</span><span class="NAME">msgDiv.css</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">left</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">left</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">top</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">top</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">						</span><span class="NAME">S.log</span><span class="PUNC">(</span><span class="STRN">'width error!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">maskDiv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>102</span> 		* @description 解除对应元素的屏蔽
<span class='line'>103</span> 		* @param {[String|DOM|Node]} element 屏蔽的元素，可以使用选择器、Dom元素，Node元素
<span class='line'>104</span> 		* @example 
<span class='line'>105</span> 		*	Grid.Util.unmaskElement('#domId');	//解除屏蔽元素，暂时只支持选择器的第一个元素
<span class='line'>106</span> 		*/</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">		</span><span class="NAME">unmaskElement</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">maskedEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">				</span><span class="NAME">maskedNode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">maskedEl.getDOMNode</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">				</span><span class="NAME">msgEl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">maskedEl.children</span><span class="PUNC">(</span><span class="STRN">'.lp-el-mask-msg'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">				</span><span class="NAME">maskDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">maskedEl.children</span><span class="PUNC">(</span><span class="STRN">'.lp-el-mask'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">msgEl</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">				</span><span class="NAME">msgEl.remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">maskDiv</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">				</span><span class="NAME">maskDiv.remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">			</span><span class="NAME">maskedEl.removeClass</span><span class="PUNC">(</span><span class="STRN">'x-masked-relative x-masked'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> 
<span class='line'>120</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>124</span> 	* 格式化数据的帮助方法
<span class='line'>125</span> 	* @class 格式化函数
<span class='line'>126</span> 	* @name Grid.Util.Format
<span class='line'>127</span> 	*/</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">	</span><span class="NAME">Util.Format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">		</span><span class="COMM">/** @lends  Grid.Util.Format */</span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>132</span> 				@description 日期格式化函数
<span class='line'>133</span> 				@param {Number|Date} date 格式话的日期，一般为1970 年 1 月 1 日至今的毫秒数 
<span class='line'>134</span> 				@return {String} 格式化后的日期格式为 2011-10-31
<span class='line'>135</span> 				@example
<span class='line'>136</span> 			* 一般用法：&lt;br> 
<span class='line'>137</span> 			* Grid.Util.Format.dateRenderer(1320049890544);输出：2011-10-31 &lt;br>
<span class='line'>138</span> 			* 表格中用于渲染列：&lt;br>
<span class='line'>139</span> 			* {title:"出库日期",dataIndex:"date",renderer:Util.Format.dateRenderer}
<span class='line'>140</span> 			*/</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">			</span><span class="NAME">dateRenderer</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">					 </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">                </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">                    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">// eval(d.replace(/\/Date\((\d+)\)\//gim, "new Date($1)"));</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">                    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">date.getFullYear</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">                    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">S.Date.format</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="STRN">"yyyy-mm-dd"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>155</span> 				@description 日期时间格式化函数
<span class='line'>156</span> 				@param {Number|Date} date 格式话的日期，一般为1970 年 1 月 1 日至今的毫秒数 
<span class='line'>157</span> 				@return {String} 格式化后的日期格式时间为 2011-10-31 16 : 41 : 02
<span class='line'>158</span> 			*/</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">			</span><span class="NAME">datetimeRenderer</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">					 </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">                </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">                    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">// eval(d.replace(/\/Date\((\d+)\)\//gim, "new Date($1)"));</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">                    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">date.getFullYear</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">                    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dateString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.Date.format</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="STRN">"yyyy-mm-dd HH:MM:ss"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">				</span><span class="COMM">//var dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + ' ' + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dateString</span><span class="PUNC">;</span><span class="COMM">//.replace(/(\s)(\d):/,' 0$2:').replace(/:(\d):/,':0$1:').replace(/:(\d)$/,':0$1'));</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>175</span> 				@description 文本截取函数，当文本超出一定数字时，会截取文本，添加...
<span class='line'>176</span> 				@param {Number} length 截取多少字符
<span class='line'>177</span> 				@return {String} 返回截取后的字符串，如果本身小于指定的数字，返回原字符串。如果大于，则返回截断后的字符串，并附加...
<span class='line'>178</span> 			*/</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">			</span><span class="NAME">cutTextRenderer</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">					</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">value.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">						</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">"..."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">					</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>189</span> 			* @description 枚举格式化函数
<span class='line'>190</span> 			* @param {Object} enumObj 键值对的枚举对象 {"1":"大","2":"小"}
<span class='line'>191</span> 			* @return {Function} 返回指定枚举的格式化函数
<span class='line'>192</span> 			* @example 
<span class='line'>193</span> 			* //Grid 的列定义
<span class='line'>194</span> 			*  {title:"状态",dataIndex:"status",renderer:Grid.Util.Format.enumRenderer({"1":"入库","2":"出库"})}
<span class='line'>195</span> 			*/</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">			</span><span class="NAME">enumRenderer</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">enumObj</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">					</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">enumObj</span><span class="PUNC">[</span><span class="NAME">value</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">			</span><span class="COMM">/*
<span class='line'>202</span> 			* @description 将多个值转换成一个字符串
<span class='line'>203</span> 			* @param {Object} enumObj 键值对的枚举对象 {"1":"大","2":"小"}
<span class='line'>204</span> 			* @return {Function} 返回指定枚举的格式化函数
<span class='line'>205</span> 			* @example 
<span class='line'>206</span> 			* //Grid 的列定义
<span class='line'>207</span> 			*  {title:"状态",dataIndex:"status",renderer:Grid.Util.multipleItemsRenderer({"1":"入库","2":"出库","3":"退货"})}
<span class='line'>208</span> 			*  //数据源是[1,2] 时，则返回 "入库,出库"
<span class='line'>209</span> 			*/</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">			</span><span class="NAME">multipleItemsRenderer</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">enumObj</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">enumFun</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Util.Format.enumRenderer</span><span class="PUNC">(</span><span class="NAME">enumObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">values</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">values</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">						</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">S.isArray</span><span class="PUNC">(</span><span class="NAME">values</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">						</span><span class="NAME">values</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">values.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">					</span><span class="NAME">S.each</span><span class="PUNC">(</span><span class="NAME">values</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">						</span><span class="NAME">result.push</span><span class="PUNC">(</span><span class="NAME">enumFun</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">					</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">					</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result.join</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>230</span> 	* 表单的一些工具方法
<span class='line'>231</span> 	* @class 格式化函数
<span class='line'>232</span> 	* @name  Grid.Util.FormHelpr
<span class='line'>233</span> 	*/</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">	</span><span class="NAME">Util.FormHelpr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">	</span><span class="COMM">/** @lends  Grid.Util.FormHelpr */</span><span class="WHIT">		</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>238</span> 		* 将表单数据序列化成为字符串
<span class='line'>239</span> 		* @param {HTMLForm} form 表单元素
<span class='line'>240</span> 		* @return {String} 序列化的字符串
<span class='line'>241</span> 		*/</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">		</span><span class="NAME">serialize</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">form</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">S.param</span><span class="PUNC">(</span><span class="NAME">Util.FormHelpr.serializeToObject</span><span class="PUNC">(</span><span class="NAME">form</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>246</span> 		* 将表单数据序列化成对象
<span class='line'>247</span> 		* @param {HTMLForm} form 表单元素
<span class='line'>248</span> 		* @return {Object} 表单元素的
<span class='line'>249</span> 		*/</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">		</span><span class="NAME">serializeToObject</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">form</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elements</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.makeArray</span><span class="PUNC">(</span><span class="NAME">form.elements</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">			</span><span class="NAME">elements</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.filter</span><span class="PUNC">(</span><span class="NAME">elements</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.id</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="NAME">item.name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">item.disabled</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">					</span><span class="PUNC">(</span><span class="NAME">this.checked</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="REGX">/select|textarea/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">item.nodeName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">						</span><span class="REGX">/text|hidden|password/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">item.type</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">arr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">			</span><span class="NAME">S.each</span><span class="PUNC">(</span><span class="NAME">elements</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">S.one</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">					</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">S.isArray</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">					</span><span class="NAME">S.map</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">							</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">elem.name</span><span class="PUNC">||</span><span class="NAME">elem.id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">					</span><span class="PUNC">{</span><span class="NAME">name</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">elem.name</span><span class="PUNC">||</span><span class="NAME">elem.id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">					</span><span class="NAME">arr.push</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">			</span><span class="NAME">S.each</span><span class="PUNC">(</span><span class="NAME">arr</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">[</span><span class="NAME">elem.name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">					</span><span class="NAME">result</span><span class="PUNC">[</span><span class="NAME">elem.name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">elem.value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">S.isArray</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">					</span><span class="NAME">prop.push</span><span class="PUNC">(</span><span class="NAME">elem.value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">					</span><span class="NAME">a.push</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">					</span><span class="NAME">a.push</span><span class="PUNC">(</span><span class="NAME">elem.value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">					</span><span class="NAME">result</span><span class="PUNC">[</span><span class="NAME">elem.name</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">		</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Util</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="NAME">requires</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"core"</span><span class="PUNC">,</span><span class="STRN">"calendar"</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>290</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>